package com.ymatou.validatecode.api.service;

import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

/**
 * 发送注册验证码Call FreeMaker Template自动生成代码
 */
public class GetMobileVerifyCodeForRegisterCall extends YmatouBaseCall {
	private static String opurl = "UserValidateApi/GetMobileVerifyCodeForRegister";

	public GetMobileVerifyCodeForRegisterCall() {
		super(EnvSetup.getSystemUrl("api_validatecode"), opurl, "GET", "PARAM");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept", "text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	/**
	 * 获取Code
	 * 
	 * @return
	 */
	public String getCode() {
		String Code = null;
		try {
			Code = new JSONObject(getReturnData()).getString("Code");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}

	/**
	 * 获取Msg
	 * 
	 * @return
	 */
	public String getMsg() {
		String msg = null;
		try {
			msg = new JSONObject(getReturnData()).getJSONObject("Data").getString("Msg");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return msg;
	}

	/**
	 * 获取IsCreateValidateCodeSuccess
	 * 
	 * @return
	 */
	public boolean isCreateValidateCodeSuccess() {
		boolean isCreateValidateCodeSuccess = false;
		try {
			isCreateValidateCodeSuccess = new JSONObject(getReturnData()).getJSONObject("Data").getBoolean(
					"IsCreateValidateCodeSuccess");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return isCreateValidateCodeSuccess;
	}
}